<template>
  <div class="storeAddress">
    <common-nav-header :title="title" />
    <ul class="storeAddressWrap" v-if="addressList.length">
      <li class="border-bottom" v-for="item in addressList" :key="item.id" @click="setAddress(item.id)">
        <p class="name">{{item.name}}</p>
        <p class="phone">电话：{{item.phone}}</p>
        <p class="address">{{item.province+item.city+item.area+item.address}}
        </p>
      </li>
    </ul>
  </div>
</template>

<script>
import CommonNavHeader from 'common/commonHeader/CommonNavHeader'
import {
  http
} from 'util/request'
import {
  storeAddr
} from 'util/netApi'
import {
  storage
} from 'util/storage'
import {
  orderInfo
} from 'util/const.js'
export default {
  name: 'StoreAddress',
  components: {
    CommonNavHeader
  },
  data () {
    return {
      title: '选择地址',
      addressList: []
      // addressId:''
    }
  },
  methods: {
    getAddress () {
      http(storeAddr).then(res => {
        this.addressList = res.data.body
      }).catch(err => {
        console.log(err)
      })
    },
    setAddress (addressId) {
      let info = storage.getLocalStorage(orderInfo) || {}
      info.addressId = addressId
      info.addressType = '上门自提'
      storage.setLocalStorage(orderInfo, info)
      this.$router.replace({path: '/createOrder/1'})
    }
  },
  created () {
    this.getAddress()
  }
}
</script>

<style lang="stylus" scoped>
  .storeAddress
    height 100%
    padding-top 120px
  .storeAddressWrap
    color #262626
    font-size 36px
    line-height 50px
    li
      padding 60px 50px
    .name
      color #000000
      font-size 46px
      height 80px
      line-height 80px
      font-weight 600
    .phone
      padding 20px 0
    li:last-child:before
      display none

</style>
